﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPivotGrid;
using System.Collections.Generic;
using DXApplicationTangche.UC.成品出库单.service;
using System.Data;
using DXApplicationTangche.Utils;
using DevExpress.XtraGrid.Demos.util;

namespace DXApplicationTangche.report
{
    public partial class XtraReport抖音退货单 : DevExpress.XtraReports.UI.XtraReport
    {
        private 出库单导出DTO 出库单导出DTO;
        private Graphics gr = Graphics.FromHwnd(IntPtr.Zero);
        
        public XtraReport抖音退货单(出库单导出DTO 出库单导出DTO)
        {
            InitializeComponent();
            String json = FunctionHelper.JsonSerialization(出库单导出DTO);
            this.出库单导出DTO = FunctionHelper.JsonDeserialization<出库单导出DTO>(json);
            this.BindData();
            DataTable dt = DataTableExtend.ToDataTable<StockInOutDetailDTO>(this.出库单导出DTO.StockInOutDetailDTOs);
            this.xrPivotGrid分录.DataSource = dt;
            this.BindTableData(this.出库单导出DTO.StockInOutDetailDTOs);
            this.DataSource = this.出库单导出DTO.StockInOutDetailDTOs;
        }
        private void BindData()
        {
            this.xrTableCell出库人.Text = this.出库单导出DTO.staffName;
            this.xrTableCell调拨入库门店.Text = this.出库单导出DTO.inStoreName;
            this.xrTableCell调拨时间.Text = this.出库单导出DTO.createDate;
            this.xrTableCell数量.Text = this.出库单导出DTO.number;
            this.xrLabel备注.Text = this.出库单导出DTO.remarks;
        }

        /// <summary>
        /// 绑定采购单明细信息
        /// </summary>
        private void BindTableData(List<StockInOutDetailDTO> stockInOutDetailDTOs)
        {
            //为XRTable的每一列绑定数据集及对应的字段
            this.xrTableCell款式1.DataBindings.Add("Text", stockInOutDetailDTOs, "styleNameCn");//款式
            this.xrTableCell面料号1.DataBindings.Add("Text", stockInOutDetailDTOs, "fabricCode");//面料号
            this.xrTableCell面料描述1.DataBindings.Add("Text", stockInOutDetailDTOs, "fabricName");//面料描述
            this.xrTableCell尺寸1.DataBindings.Add("Text", stockInOutDetailDTOs, "styleSizeCd");//尺寸
            this.xrTableCell价格1.DataBindings.Add("Text", stockInOutDetailDTOs, "price");//价格
            this.xrTableCell成衣条码1.DataBindings.Add("Text", stockInOutDetailDTOs, "barcode");//成衣条码
        }

        public XtraReport抖音退货单 抖音退货()
        {
            this.xrLabel出库类型.Text = "抖音退货入库单";
            // 表头
            this.出库人.BackColor = Color.Blue;
            this.xrTableCell1.BackColor = Color.Blue;
            this.xrTableCell2.BackColor = Color.Blue;
            this.出库人.ForeColor = Color.White;
            this.xrTableCell1.ForeColor = Color.White;
            this.xrTableCell2.ForeColor = Color.White;
            // 分录
            this.xrTableCell款式0.BackColor = Color.Blue;
            this.xrTableCell面料号0.BackColor = Color.Blue;
            this.xrTableCell面料描述0.BackColor = Color.Blue;
            this.xrTableCell尺寸0.BackColor = Color.Blue;
            this.xrTableCell价格0.BackColor = Color.Blue;
            this.xrTableCell成衣条码0.BackColor = Color.Blue;
            this.xrTableCell款式0.ForeColor = Color.White;
            this.xrTableCell面料号0.ForeColor = Color.White;
            this.xrTableCell面料描述0.ForeColor = Color.White;
            this.xrTableCell尺寸0.ForeColor = Color.White;
            this.xrTableCell价格0.ForeColor = Color.White;
            this.xrTableCell成衣条码0.ForeColor = Color.White;

            this.Watermark.Text = "抖音退货入库";
            this.Watermark.ForeColor = Color.Blue;
            return this;
        }
    }
}
